home *** CD-ROM | disk | FTP | other *** search
- /*
- Search for file names
- ending in #?bak, and then
- delete them if necessary.
- © John Kennedy
- */
-
- address command /* Use AmigaDOS */
-
- /* First, generate list of files & sizes */
-
- Say "Making list of all files in current directory...."
-
- 'list lformat "%p%n %l" all files > t:templist'
-
-
- /* Now, search for those ending in .bak */
-
- Say "Adding up file sizes.."
-
- infile='infile'
- outfile='outfile'
-
- total_size=0
- number=0
-
- call open(outfile,'t:report','w')
- call open(infile,"t:templist",'r')
-
- do while ~eof(infile)
- data=readln(infile)
- if data~='' then do
- parse var data namepath " " size
- if size='empty' then size=0
- test=right(namepath,4)
- if (test='.bak') then do
- total_size=total_size+size
- number=number+1
- call writeln(outfile,namepath)
- end
- end
- end
- call close(infile)
- call close(outfile)
-
- /* Process the files if required */
-
- say "Number of backup files:" number
- say "Drive space taken up: " total_size
- say
-
- if number~=0 then call ProcessFiles()
-
- /* All done! */
-
- 'delete "t:report" quiet'
- 'delete "t:templist" quiet'
-
- say "Finished."
- exit
-
-
-
-
- ProcessFiles:
-
- answer=''
- do while (answer~="D" & answer~="C")
- say "[D]elete files or [C]ancel?"
- parse pull answer
- answer=upper(answer)
- end
-
- select
- when answer='D' then call DeleteFiles()
- when answer='C' then return
- end
-
- return
-
-
- DeleteFiles:
-
- answer=''
- confirm='Y'
- do while (answer~="A" & answer~="C")
- say "Delete [A]ll or [C]onfirm each one?"
- parse pull answer
- answer=upper(answer)
- end
-
- call open(infile,"t:report",'r')
- do n=1 to number
- file=readln(infile)
- data='delete '||d2c(34)||file||d2c(34)
-
-
- if (answer="C") then
- do
- confirm=''
- do while (confirm~="Y" & confirm~="N" & confirm~="Q")
- say "Delete " || file || " [Y]es, [N]o, [Q]uit?"
- parse pull confirm
- confirm=upper(confirm)
- end
- end
-
- if (confirm="Y") then interpret(data)
- if (confirm="Q") then leave
-
- end
- call close(infile)
- return
-